// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import ElementUI from 'element-ui'
import App from './App'
import router from './router'
import store from './store'
import 'element-ui/lib/theme-chalk/index.css'
import { setCookie, getCookie, delCookie } from './assets/scripts/cookie/cookie.js'
import axios from './until/fetch'
import './assets/css/style.css'
import 'lib-flexible/flexible'

Vue.use(ElementUI)
Vue.prototype.$cookieStore = { setCookie, getCookie, delCookie }
Vue.config.productionTip = false
Vue.prototype.$axios = axios

// console.log(this.$store.state.show)
/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  store,
  components: { App },
  created() {
    if (localStorage.getItem('apiToken') == null) {
      localStorage.getItem('apiToken', '')
    }
    this.$store.state.token = localStorage.getItem('apiToken')
    let customer
    if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) {
      customer = 'iPhone'
    } else if (/(Android)/i.test(navigator.userAgent)) {
      customer = 'Android'
    } else {
      customer = 'pc'
    }
    this.$store.commit('updatePort', customer)
  },
  template: '<App/>'
})
